"use strict";
/**
 * @ Author: Yoann Meclot. MSay2
 * @ Created on: 2020-09-03 13:21:55
 * @ Modified on: 2021-06-14 18:29:55
 *
 * @version 1.2
 */
/**
 * Copyright (c) 2020-2021 MSay2 (Yoann Meclot) - @msay2/tspoet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSAnnotation = void 0;
const ArrayList_js_1 = require("../util/list/ArrayList.js");
const Utils_js_1 = require("../util/Utils.js");
const ObjectName_js_1 = require("./ObjectName.js");
/**
 * TSAnnotation allows you to write a annotation imported or not.
 *
 * Use static field to write empty value.
 *
 * @class `TSAnnotation`
 * @version 1.2
 */
class TSAnnotation {
    constructor(builder) {
        this.mName = builder.mName;
        this.mValues = builder.mValues;
        this.mImports = builder.mImports;
    }
    /**
     * Build annotation.
     *
     * @param objectName The object name to be imported.
     * @throws {TSPoetException} Check if the name is undefined or null.
     * @type {TSAnnotation.Builder}
     * @since 1.0
     */
    static annotationBuilder(objectName) {
        return new TSAnnotation.Builder(objectName);
    }
    emit(codeWriter) {
        codeWriter.emitAnnotation(this);
        return codeWriter;
    }
}
exports.TSAnnotation = TSAnnotation;
/**
 * Static field to write empty value.
 *
 * @type {string}
 * @since 1.0
 */
TSAnnotation.EMPTY_VALUE = "msay2.tspoet:EMPTY_VALUE";
TSAnnotation.Builder = class Builder {
    constructor(name) {
        this.mValues = new ArrayList_js_1.ArrayList();
        this.mImports = new ArrayList_js_1.ArrayList();
        this.mName = Utils_js_1.Preconditions.checkNotNull(name, "annotation name", "name").asType().getName();
        this.putImport(name);
    }
    /**
     * Add value to the annotation.
     *
     * @param value The value of annotation.
     * @throws {TSPoetException} Check if the value is undefined or null.
     * @type {TSAnnotation.Builder}
     * @since 1.0
     */
    addValue(value) {
        this.mValues.add(Utils_js_1.Preconditions.checkNotNull(value, "annotation value", "value"));
        if (value instanceof ObjectName_js_1.ObjectName)
            this.putImport(value);
        return this;
    }
    /**
     * Build annotation.
     *
     * @type {TSAnnotation}
     * @since 1.0
     */
    build() {
        return new TSAnnotation(this);
    }
    putImport(objectName) {
        this.mImports.add(objectName);
    }
};
//# sourceMappingURL=TSAnnotation.js.map